# coding=utf-8
import redis
import logging


# 创建配置类
class config_cls(object):
    # 数据库的配置
    # SQLAlCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/iHome"
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/ihome"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis的配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    SECRET_KEY = 'dycnXaNu9Low2BH79WyJ2unHX6Ml65rQI8i/g9ibAJNi6WAtNjTIKFU+UEJu6vUr'

    # 设置session配置
    SESSION_TYPE = 'redis'
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    PERMANENT_SESSION_LIFETIME = 7200


class DevelopmentConfigcls(config_cls):
    # 开发阶段的配置类
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfigcls(config_cls):
    # 生产阶段的配置类
    LOG_LEVEL = logging.WARNING


config_dict = {
    'development': DevelopmentConfigcls,
    'production': ProductionConfigcls
}
